// 参考文档 https://segmentfault.com/a/1190000039706418
const bind2 = ()=>{
  let data = {
    name: [],
  }
  Object.keys(data).forEach(key=>{
    defineProperty(data, key, data[key])
  })
  function defineProperty(target, key, value) {
    Object.defineProperty(target,key,{
        get() {
            console.log('这里监听到了数据获取')
            return value
        },
        set(newValue, value) {
            if(newValue !== value) {
                value = newValue
                console.log('这里监听到了数据更改')
            }
        }
    })
  }
  data.name.push('nike') 
}

const bind3 = ()=>{
  let data = {
    msg:{
      a:1
    },
    arr:[223,5]
  }
  let handler = {
    get(target, key){
      if(typeof target[key] ==='object' && target[key]!==null){
        return new Proxy(target[key],handler)
      }
      return Reflect.get(target, key)
    },
    set(target,key,value){
      let oldvalue = target[key];
      if(oldvalue!==value){

      }
      return Reflect.set(target,key,value)
    }
  }
  let proxy = new Proxy(data, handler);
  proxy.arr.push(4)
}